<?php
namespace Common\Library;

/**
 * 公司对象工厂
 * Class CompanyModel
 * @package Common\Library
 */
class CompanyDao {

    /**
     * 获取当前登陆的用户
     */
    public static function FetchCurrent(){
        if(empty($_SESSION['cp_id'])) return null;
        return self::FetchOne($_SESSION['cp_id']);
    }

    /**
     * 获取所有公司对象
     */
    public static function FetchAll(){

    }

    /**
     * 根据ID获取公司对象
     * @param int $id 公司ID
     * @return CompanyModel
     */
    public static function  FetchOne($id){
        $companyModel = D('company');
        $data = $companyModel->where(['cp_id'=>$id])->select();
        $company = new CompanyModel();
        $company->id = $data[0]['cp_id'];
        $company->name = $data[0]['cp_name'];
        $company->username = $data[0]['cp_user'];
        $company->password = $data[0]['cp_psw'];
        $company->time = $data[0]['cp_time'];
        return $company;
    }

}

$a;

function sdsd(){
    $this->a;
}